package rhinestone.Model;

import java.util.HashMap;
import java.io.Serializable;

/**
 *
 * @author Group 2
 * @version 2010.12.23
 */
public class LeaseContainer implements Serializable {
	private HashMap<Integer, Lease> pendingLeases;
	private HashMap<Integer, Lease> leaseHistory;
	private static LeaseContainer instance;
	private boolean changed;

	private LeaseContainer() {
		pendingLeases = new HashMap<Integer, Lease>();
		leaseHistory = new HashMap<Integer, Lease>();
		changed = false;
	}

	public static LeaseContainer getInstance() {
		if(instance == null)
			instance = new LeaseContainer();
		return instance;
	}

	public void addLease(Lease lease) {
		pendingLeases.put(lease.getId(), lease);
		changed = true;
	}

	public Lease getLease(int id) {
		Lease lease = pendingLeases.get(id);
		if(lease == null)
			lease = leaseHistory.get(id);
		return lease;
	}

	public boolean isChanged() {
		return changed;
	}

	public void setChanged(boolean changed) {
		this.changed = changed;
	}
}
